package com.dragon.repository.domain.dto;

import com.dragon.repository.entity.QuartzJob;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.dragon.common.util.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class QuartzJobDTO {

    private static final long serialVersionUID = 1L;

    private String id;

    @ApiModelProperty(value = "创建人")
    private String createBy;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "删除状态")
    private Integer delFlag;

    @ApiModelProperty(value = "修改人")
    private String updateBy;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "任务类名")
    private String jobClassName;

    @ApiModelProperty(value = "cron表达式")
    private String cronExpression;

    @ApiModelProperty(value = "参数")
    private String parameter;

    @ApiModelProperty(value = "描述")
    private String description;

    @ApiModelProperty(value = "状态0正常-1停止")
    private Integer status;


    public QuartzJobDTO() {}

    public QuartzJobDTO(QuartzJob entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static QuartzJobDTO convert(QuartzJob entity) {
        return new QuartzJobDTO(entity);
    }

    public static List<QuartzJobDTO> convertList(List<QuartzJob> list) {
        List<QuartzJobDTO> resultList = new ArrayList<>();
        for (QuartzJob entity : list) {
            resultList.add(new QuartzJobDTO(entity));
        }
        return resultList;
    }}
